GAI-3101 Lab Guide

Crafting Custom Agentic AI Solutions

Accessing and Running Labs in Amazon SageMaker

Module 1

The labs in this course use Amazon SageMaker to host Jupyter Lab environments. This section provides an overview of SageMaker and guides you through accessing and using the Jupyter Lab interface.

1.1. Logging into the AWS Console

Note

Your credentials are available in the student portal. If you don’t have access to the portal, ask the instructor for help.
Please log into AWS with your assigned credentials. AWS is a cloud technology and is frequently updated. As a result, you may have to improvise if there are changes in the interface. Please don’t hesitate to ask your instructor if there are any questions.

  1. Open your preferred web browser and navigate to: https://console.aws.amazon.com

  2. Select "IAM User"

  3. Enter your account alias.

  4. Press Next

    AWS Console Login Page
  5. Sign in with your AWS credentials

    AWS I AM Login Page

1.2. Navigating to Amazon Sagemaker AI

From the AWS Console, you will be able to access the AWS Sagemaker AI environment.

  1. In the AWS Management Console search bar, type "SageMaker AI"

    AWS Sagemaker AI search
  2. Open Sagemaker dashboard by clicking the result for "Amazon Sagemaker AI"

  3. In the SageMaker dashboard, click on "Notebooks" in the left sidebar

  4. Under the "Notebook Instances" header, you will see a list of existing Notebook instances.

    AWS Sagemaker panel

    Important

    If you don’t see any existing notebooks, check these things:

    • Make sure you’re in the correct AWS region (typically us-west-2).
    • Make sure to use the correct account if you have multiple AWS accounts.

    Ask the instructor for help if you’re still unable to locate the SageMaker notebook.

1.3. Managing Notebook Instances

Notebook instances are the primary lab environment for SageMaker. You can start, stop, and manage these instances from the SageMaker dashboard. The status for each notebook instance is displayed in the "Status" column.

The primary states are:

  • InService: The notebook instance is running and ready to use
  • Stopped: The notebook instance is stopped and not incurring compute charges
  • Pending: The notebook instance is being provisioned

1.3.1. Starting a Notebook Instance

To start a new notebook instance click the "Start" button next to the notebook instance name.

aws start notebook

1.3.2. Stopping a Notebook Instance

To stop a notebook instance:

  1. Select the notebook instance by clicking the name

  2. Click Actions ▸ Stop next to the notebook instance name.

aws actions stop

1.4. Accessing Jupyter Lab

Once the notebook is "InService" you can access the Jupyter Lab environment by clicking the "Open JupyterLab" button next to the notebook instance name.

aws08 open jupyter lab

1.5. Working with JupyterLab

If you have not worked with Jupyter Lab before, it’s a powerful tool for data science and machine learning workflows. This section will guide you through creating your first notebook and writing some code. If you’re already familiar with Jupyter Lab, you can skip this section.

  1. Click the "+" button in the top left corner of Jupyter Lab to open the Launcher

  2. Under "Notebook" select conda_python3 instance

    • This creates a Jupyter notebook kernel of type conda_python3
      aws conda python3
  3. Right-click the Notebook name on the left-side menu, and select Rename (default is “Untitled.ipynb”)

    aws rename notebook
  4. Enter the new name: SageMaker_Introduction.ipynb

  5. In the first cell, enter the following code and execute it with Shift+Enter or by pressing "Play" button on the toolbar:

    print("Welcome to SageMaker!")
  6. In the next cell, import common libraries and verify your SageMaker setup:

    import numpy as np
    import pandas as pd
    import sagemaker
    from sagemaker import get_execution_role
    
    # Get the SageMaker execution role
    role = get_execution_role()
    print(f"SageMaker Role: {role}")

1.6. Essential Jupyter Lab Operations

Understanding keyboard shortcuts and cell operations will significantly improve the lab experience. Here are some essential shortcuts and operations to get you started.

1.6.1. Command Mode Shortcuts

To enter command mode, press Esc. Then use these shortcuts:

Shortcut Action

A

Insert cell above

B

Insert cell below

DD

Delete cell

M

Change to Markdown cell

Y

Change to code cell

Shift+Enter

Run cell and move to next

1.6.2. Edit Mode Shortcuts

To enter edit mode, press Enter. Then use these shortcuts:

Shortcut Action

Shift+Enter

Run cell and move to next

Ctrl+Enter

Run cell and stay

Alt+Enter

Run cell and insert below

Practice Exercise
  1. Create a new cell (press B)

  2. Enter this markdown text:

    # My First SageMaker Notebook
    This notebook demonstrates basic SageMaker functionality.
  3. Convert to markdown (click outside shell, press M)

  4. Execute the cell (press Shift+Enter)

1.6.3. Save Your Work

Proper saving ensures your work is preserved between sessions.

  1. Save your notebook:

    • Press Ctrl+S, or
    • Click File → Save Notebook
  2. Download a local backup:

    1. Click File → Download

    2. Select "Notebook (.ipynb)"

Creating a Simple Python Agent

Module 2

  1. Open the Jupyter Notebook file simple-python-agent/simple-python-agent.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Implementing Round Robin Communication with AutoGen

Module 3

  1. Open the Jupyter Notebook file round-robin-chat/round-robin-chat.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Implementing a Reactive Agent in AutoGen

Module 4

  1. Open the Jupyter Notebook file autogen-reactive-agent/autogen-reactive-agent.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Implementing a Deliberative Agent in LangGraph

Module 5

  1. Open the Jupyter Notebook file langgraph-deliberative-agent/langgraph-deliberative-agent.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Building an Agent with Long-Term Memory

Module 6

  1. Open the Jupyter Notebook file long-term-memory/long-term-memory.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Integrating an Observation Tool in an Agent

Module 7

  1. Open the Jupyter Notebook file using-observation-tools/using-observation-tools.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Integrating an Action Tool in an Agent

Module 8

  1. Open the Jupyter Notebook file using-action-tools/using-action-tools.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Implementing a Hierarchical Planning Strategy

Module 9

  1. Open the Jupyter Notebook file hierarchical-planning/hierarchical-planning.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Building an Agent with Rule-Based Reasoning

Module 10

  1. Open the Jupyter Notebook file rule-based-reasoning/rule-based-reasoning.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Evaluating the Robustness of an Agentic System

Module 11

  1. Open the Jupyter Notebook file evaluating-agentic-robustness/evaluating-agentic-robustness.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Building a Personal Assistant Agent

Module 12

  1. Open the Jupyter Notebook file building-personal-assistant/building-personal-assistant.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.

Implementing Error Recovery and Resilience

Module 13

  1. Open the Jupyter Notebook file implementing-error-recovery/implementing-error-recovery.ipynb in the Jupyter Lab environment.

  2. Follow the instructions in the notebook to complete the lab.